
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.soldier.dto.CommonSmsPoolDTO;
import com.insigma.business.qrcode.soldier.entity.CommonSmsPoolDO;
import com.insigma.business.qrcode.soldier.request.CommonSmsPoolBSearcher;
import com.insigma.business.qrcode.soldier.request.CommonSmsPoolInsertRequest;
import com.insigma.business.qrcode.soldier.request.CommonSmsPoolSearchRequest;
import com.insigma.business.qrcode.soldier.request.CommonSmsPoolUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonSmsPoolProviderConverter extends AbstractConverter<CommonSmsPoolDTO, CommonSmsPoolDO> {

    private final static CommonSmsPoolProviderConverter commonSmsPoolConverter = new CommonSmsPoolProviderConverter();

    private CommonSmsPoolProviderConverter(){}

    
    public static CommonSmsPoolBSearcher convertRequestSO2Searcher(final CommonSmsPoolSearchRequest request){
        final CommonSmsPoolBSearcher commonSmsPoolBSearcher = new CommonSmsPoolBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonSmsPoolBSearcher);
        return commonSmsPoolBSearcher;
    }

    
    public static CommonSmsPoolDO convertRequestUO2DO(final CommonSmsPoolUpdateRequest commonSmsPoolUpdateRequest) {
        final CommonSmsPoolDO commonSmsPoolDO = new CommonSmsPoolDO();
        BeanUtils.copyProperties(commonSmsPoolUpdateRequest,commonSmsPoolDO);
        
        return commonSmsPoolDO;
    }

    
    public static CommonSmsPoolDO convertRequestIO2DO(final CommonSmsPoolInsertRequest commonSmsPoolInsertRequest) {
        final CommonSmsPoolDO commonSmsPoolDO = new CommonSmsPoolDO();
        BeanUtils.copyProperties(commonSmsPoolInsertRequest,commonSmsPoolDO);
        return commonSmsPoolDO;
    }

    
    public static List<CommonSmsPoolDTO> convertResponseDOList2DTOList(final List<CommonSmsPoolDO> commonSmsPoolDOList){
        return commonSmsPoolConverter.convertGenericResponseDOList2DTOList(commonSmsPoolDOList);
    }

    
    public static CommonSmsPoolDTO convertResponseDO2DTO(final CommonSmsPoolDO commonSmsPoolDO){
        return commonSmsPoolConverter.convertGenericResponseDO2DTO(commonSmsPoolDO);
    }

    
    @Override
    protected CommonSmsPoolDTO doConvertResponseDO2DTO(CommonSmsPoolDO commonSmsPoolDO) {
        final CommonSmsPoolDTO commonSmsPoolDTO = new CommonSmsPoolDTO();
        try {
            BeanUtils.copyProperties(commonSmsPoolDO, commonSmsPoolDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonSmsPoolDTO;
    }

}
